<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class authen_model extends CI_Model {

    public function __construct() {
        error_reporting(0);
        parent::__construct();
    }
    
    public function check_user_db($name , $pass , $account_type){
        switch ($account_type){
            case "class_a":
                $this->db->select("*")->from("admin")
                     ->where("admin_username" , "$name" )
                     ->where("admin_password",md5("$pass"))
                     ->limit(1);
                break;
            case "class_t":
                $this->db->select("*")->from("teachers")
                     ->where("teacher_code" , "$name" )
                     ->where("teacher_date" , "$pass")
                     ->limit(1);
                break;
            case "class_c":
                $this->db->select("*")->from("collegian")
                     ->where("collegian_code" , "$name" )
                     ->where("collegian_date" , "$pass")
                     ->limit(1);
                break;
        }
        return $this->db->get();
    }
    
   public function CheckPermission(){
       session_start();
       if(!isset($_SESSION["username"],$_SESSION["id"])){
            @header( 'Location: ' . base_url() . "authen/login/_file/timeout_login.go") ;
       }
   }
    
}
?>
